package com.wz.project.bas.workshopNowClass.controller;

import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.framework.web.page.TableDataInfo;
import com.wz.project.bas.workshopNowClass.domain.WorkshopNowClass;
import com.wz.project.bas.workshopNowClass.service.IWorkshopNowClassService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 基础当前车间班组 信息操作处理
 *
 * @author sys
 * @date 2021-10-28
 */
@Controller
@RequestMapping("/bas/workshopNowClass")
public class WorkshopNowClassController extends BaseController {
    private String prefix = "bas/workshopNowClass";

    @Autowired
    private IWorkshopNowClassService workshopNowClassService;

    @RequiresPermissions("bas:workshopNowClass:view")
    @GetMapping()
    public String workshopNowClass() {
        return prefix + "/workshopNowClass";
    }

    /**
     * 查询基础当前车间班组列表
     */
//	@RequiresPermissions("module:workshopNowClass:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WorkshopNowClass workshopNowClass) {
        startPage();
        List<WorkshopNowClass> list = workshopNowClassService.selectWorkshopNowClassList(workshopNowClass);
        return getDataTable(list);
    }

    /**
     * 新增基础当前车间班组
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存基础当前车间班组
     */
    @RequiresPermissions("module:workshopNowClass:add")
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WorkshopNowClass workshopNowClass) {
        return toAjax(workshopNowClassService.insertWorkshopNowClass(workshopNowClass));
    }

    /**
     * 修改基础当前车间班组
     */
    @GetMapping("/edit/{lineId}")
    public String edit(@PathVariable("lineId") String lineId, ModelMap mmap) {
        WorkshopNowClass workshopNowClass = workshopNowClassService.selectWorkshopNowClassById(lineId);
        mmap.put("workshopNowClass", workshopNowClass);
        return prefix + "/edit";
    }

    /**
     * 修改保存基础当前车间班组
     */
    @RequiresPermissions("module:workshopNowClass:edit")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WorkshopNowClass workshopNowClass) {
        return toAjax(workshopNowClassService.updateWorkshopNowClass(workshopNowClass));
    }

    /**
     * 删除基础当前车间班组
     */
    @RequiresPermissions("module:workshopNowClass:remove")
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(workshopNowClassService.deleteWorkshopNowClassByIds(ids));
    }

}
